package leetcode.D800.T714;

/**
 * @File Info: leetcode -- <Solution>
 * @Author: 18362
 * @Create: 2022-02-22 16:57:17 星期二
 */

class Solution {
    public int maxProfit(int[] prices, int fee) {
        int dp0 = 0, dp1 = -prices[0]-fee;
        for(int i=1; i<prices.length; ++i) {
            int t0 = dp0, t1 = dp1;
            dp0 = Math.max(t0, t1+prices[i]);
            dp1 = Math.max(t0-prices[i]-fee, t1);
        }
        return dp0;
    }
}